<include file="Public/min-header"/>

<!--以下是在线编辑器 代码 -->
<script type="text/javascript">
    /*
     * 在线编辑器相 关配置 js
     *  参考 地址 http://fex.baidu.com/ueditor/
     */
    window.UEDITOR_Admin_URL = "__ROOT__/Public/plugins/Ueditor/";
    var URL_upload = "{$URL_upload}";
    var URL_fileUp = "{$URL_fileUp}";
    var URL_scrawlUp = "{$URL_scrawlUp}";
    var URL_getRemoteImage = "{$URL_getRemoteImage}";
    var URL_imageManager = "{$URL_imageManager}";
    var URL_imageUp = "{$URL_imageUp}";
    var URL_getMovie = "{$URL_getMovie}";
    var URL_home = "{$URL_home}";
</script>
<script type="text/javascript" charset="utf-8" src="__ROOT__/Public/plugins/Ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__ROOT__/Public/plugins/Ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__ROOT__/Public/plugins/Ueditor/lang/zh-cn/zh-cn.js"></script>
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<script type="text/javascript">

    var editor;
    $(function () {
        //具体参数配置在  editor_config.js  中
        var options = {
            zIndex: 999,
            initialFrameWidth: "95%", //初化宽度
            initialFrameHeight: 400, //初化高度
            focus: false, //初始化时，是否让编辑器获得焦点true或false
            maximumWords: 99999, removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign'
            , //允许的最大字符数 'fullscreen',
            pasteplain:false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
            autoHeightEnabled: true
            /*   autotypeset: {
             mergeEmptyline: true,        //合并空行
             removeClass: true,           //去掉冗余的class
             removeEmptyline: false,      //去掉空行
             textAlign: "left",           //段落的排版方式，可以是 left,right,center,justify 去掉这个属性表示不执行排版
             imageBlockLine: 'center',    //图片的浮动方式，独占一行剧中,左右浮动，默认: center,left,right,none 去掉这个属性表示不执行排版
             pasteFilter: false,          //根据规则过滤没事粘贴进来的内容
             clearFontSize: false,        //去掉所有的内嵌字号，使用编辑器默认的字号
             clearFontFamily: false,      //去掉所有的内嵌字体，使用编辑器默认的字体
             removeEmptyNode: false,      //去掉空节点
             //可以去掉的标签
             removeTagNames: {"font": 1},
             indent: false,               // 行首缩进
             indentValue: '0em'           //行首缩进的大小
             }*/,
            toolbars: [
                ['fullscreen', 'source', '|', 'undo', 'redo',
                    '|', 'bold', 'italic', 'underline', 'fontborder',
                    'strikethrough', 'superscript', 'subscript',
                    'removeformat', 'formatmatch', 'autotypeset',
                    'blockquote', 'pasteplain', '|', 'forecolor',
                    'backcolor', 'insertorderedlist',
                    'insertunorderedlist', 'selectall', 'cleardoc', '|',
                    'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                    'customstyle', 'paragraph', 'fontfamily', 'fontsize',
                    '|', 'directionalityltr', 'directionalityrtl',
                    'indent', '|', 'justifyleft', 'justifycenter',
                    'justifyright', 'justifyjustify', '|', 'touppercase',
                    'tolowercase', '|', 'link', 'unlink', 'anchor', '|',
                    'imagenone', 'imageleft', 'imageright', 'imagecenter',
                    '|', 'insertimage', 'emotion', 'insertvideo',
                    'attachment', 'map', 'gmap', 'insertframe',
                    'insertcode', 'webapp', 'pagebreak', 'template',
                    'background', '|', 'horizontal', 'date', 'time',
                    'spechars', 'wordimage', '|',
                    'inserttable', 'deletetable',
                    'insertparagraphbeforetable', 'insertrow', 'deleterow',
                    'insertcol', 'deletecol', 'mergecells', 'mergeright',
                    'mergedown', 'splittocells', 'splittorows',
                    'splittocols', '|', 'print', 'preview', 'searchreplace']
            ]
        };
        editor = new UE.ui.Editor(options);
        editor.render("certificate");  //  指定 textarea 的  id 为 goods_content

    });
</script>
<!--以上是在线编辑器 代码  end-->


<div class="wrapper">
    <!-- Content Header (Page header) -->
    <include file="Public/breadcrumb"/>
    <section class="content">
        <!-- Main content -->
        <!--<div class="container-fluid">-->
        <div class="row">
            <div class="col-sm-12">
                <div class="panel panel-default">
                    <div class="pull-right">
                        <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
                    </div>
                    <div class="panel-heading">
                        <h3 class="panel-title"><i class="fa fa-list"></i>
                            <if condition="$user neq ''" >
                                修改教练信息
                                <else/>
                                添加教练
                            </if>

                        </h3>
                    </div>
                    <div class="panel-body">
                        <form action="{:U('saveCoach')}" method="post" enctype="multipart/form-data" onsubmit="return checkUserUpdate(this);">

                            <input name="id" id="id" value="{$user['id']}" type="hidden">


                            <table class="table table-bordered">
                                <tbody>

                                <tr class="coupon_sec4">
                                    <td class="col-sm-1">选择会员:</td>
                                    <td class="col-sm-11">
                                        <div class="form-group">
                                            <a class="btn btn-primary" href="javascript:void(0);" onclick="selectUser()" ><i class="fa fa-search"></i>搜索用户</a>
                                        </div>
                                    </td>
                                </tr>

                                <tr class="coupon_sec4">
                                    <td colspan="2">
                                       <div class="form-group">
                                       		<table class="table table-bordered">
                                       			<thead>
                                       			<tr>
                                       				<th style="display:none">选择</th>
									                <th class="text-left">头像</th>
									                <th class="text-left">昵称</th>
									                <th class="text-left">操作</th>
									            </tr>
									            </thead>
									            <tbody id="goods_list">
									            <foreach name="prom_goods" item="vo">
									            	<tr>
									            		<td style="display:none"><input type="checkbox" name="goods_id[]" checked="checked" value="{$vo.goods_id}"/></td>
									                	<td class="text-left">{$vo.goods_name}</td>

									                	<td class="text-left"><a href="javascript:void(0)" onclick="javascript:$(this).parent().parent().remove();">删除</a></td>
									           		</tr>
									           </foreach>
									           </tbody>
                                       		</table>
                                         </div>
                                    </td>
                                </tr>


                                <!--<tr>-->
                                    <!--<td>是否教练:</td>-->
                                    <!--<td id="">-->
                                        <!--<input name="is_open" type="radio" value="0" <if condition="$user['is_open'] eq 0">checked</if> >普通员工-->
                                        <!--<input name="is_open" type="radio" value="1" <if condition="$user['is_open'] eq 1">checked</if> >教练-->
                                    <!--</td>-->
                                    <!--<td></td>-->
                                <!--</tr>-->

                                <tr  >
                                    <td>选择类型:</td>
                                    <td>
                                        <select name="is_open" id="is_open" onchange="set_jl_cate();" class="form-control" style="width:250px;">
                                            <option value="1"  <if condition="1 eq $user['is_open'] ">selected="selected"</if>>普通员工</option>
                                            <option value="2"  <if condition="2 eq $user['is_open'] or  '' eq $user[is_open] ">selected="selected"</if>>教练</option>
                                        </select>
                                    </td>
                                </tr>



                                <tr  class="coach_tr">
                                    <td>所属分类1:</td>
                                    <td>
                                        <select name="cate_id" id="cate_id" class="form-control" style="width:250px;">
                                            <option value="0">--请选择分类--</option>

                                            <foreach name="cat_list" item="v" key="k" >
                                                <option value="{$v['id']}"  <if condition="$v['id'] eq $user['cate_id'] ">selected="selected"</if>>
                                                {$v['name']}
                                                </option>
                                            </foreach>
                                        </select>
                                    </td>
                                </tr>


                                <tr class="coach_tr" >
                                    <td>所属分类2:</td>
                                    <td>
                                        <select name="cate_id2" id="cate_id2" class="form-control" style="width:250px;">
                                            <option value="0">--请选择分类--</option>

                                            <foreach name="cat_list" item="v" key="k" >
                                                <option value="{$v['id']}"  <if condition="$v['id'] eq $user['cate_id2'] ">selected="selected"</if>>
                                                {$v['name']}
                                                </option>
                                            </foreach>
                                        </select>
                                    </td>
                                </tr>


                                <tr class="coach_tr" >
                                    <td>所属分类3:</td>
                                    <td>
                                        <select name="cate_id3" id="cate_id3" class="form-control" style="width:250px;">
                                            <option value="0">--请选择分类--</option>

                                            <foreach name="cat_list" item="v" key="k" >
                                                <option value="{$v['id']}"  <if condition="$v['id'] eq $user['cate_id3'] ">selected="selected"</if>>
                                                {$v['name']}
                                                </option>
                                            </foreach>
                                        </select>
                                    </td>
                                </tr>

                                <tr >
                                    <td class="col-sm-2">真实姓名:</td>
                                    <td ><input type="text" class="form-control" name="name" value="{$user.name}" style="width: 300px;"></td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td class="col-sm-2">昵称:</td>
                                    <td ><input type="text" class="form-control" name="nickname" value="{$user.nickname}" style="width: 300px;"></td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td class="col-sm-2">联系电话:</td>
                                    <td ><input type="text" class="form-control"  id="tel" name="tel" value="{$user.tel}" style="width: 300px;"></td>
                                    <td></td>
                                </tr>


                               <!-- <tr class="coach_tr">
                                    <td class="col-sm-2">教练等级:</td>
                                    <td >
                                        <select name="grade_id" id="grade_id" class="form-control" style="width:250px;">
                                            <option value="0">&#45;&#45;请选择等级&#45;&#45;</option>
                                            <foreach name="coach_grade" item="v" key="k" >
                                                <option <if condition="$user[grade_id] eq $k">selected="selected" </if> value="{$k}">{$v}</option>
                                            </foreach>
                                        </select>
                                    </td>
                                    <td></td>
                                </tr>-->

                              <!--  <tr>
                                    <td>性别:</td>
                                    <td id=" ">
                                        <input name="sex" type="radio" value="0" <if condition="$user['sex'] eq 0">checked</if> >保密
                                        <input name="sex" type="radio" value="1" <if condition="$user['sex'] eq 1">checked</if> >男
                                        <input name="sex" type="radio" value="2" <if condition="$user['sex'] eq 2">checked</if> >女
                                    </td>
                                    <td></td>
                                </tr>-->
                              <!--  <tr>
                                    <td class="col-sm-2">座右铭:</td>
                                    <td ><input type="text" class="form-control" name="motto" value="{$user.motto}"></td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>专业: </td>
                                    <td>
                                        <textarea rows="4" cols="60" id="skill" name="skill" placeholder="多个用换行隔开">{$user.skill}</textarea>
                                    </td>
                                </tr>-->






                                <tr class="coach_tr">
                                    <td>特长:</td>
                                    <td>
                                        <textarea rows="4" cols="60" id="speciality" name="speciality" placeholder="多个用换行隔开">{$user.speciality}</textarea>
                                    </td>
                                </tr>
<!--
                                <tr>
                                    <td>描述:</td>
                                    <td>
                                        <textarea rows="4" cols="60" id="describe" name="describe">{$user.describe}</textarea>
                                    </td>
                                </tr>-->
                                <tr class="coach_tr">

                                    <td>上传头像: </td>
                                    <td>
                                        <input type="file" name="file" >
                                        <php>if(!empty($user['images'])){</php>
                                        <img src="{$user.images}" style="width:50px;"/>
                                        <php>}</php>
                                    </td>
                                </tr>
                                <tr class="coach_tr">

                                    <td>上传介绍图片:<br/> </td>
                                    <td>
                                        <input type="file" name="file_banner" >
                                        <php>if(!empty($user['images_banner'])){</php>
                                        <img src="{$user.images_banner}" style="width:50px;"/>
                                        <php>}</php>
                                    </td>
                                </tr>




                                <tr class="coach_tr">
                                    <td>证书:</td>
                                    <td width="85%">
                                        <textarea class="span12 ckeditor" id="certificate" name="certificate" title="">{$user.certificate}</textarea>
                                        <span id="err_certificate" style="color:#F00; display:none;"></span>
                                    </td>
                                </tr>

                                <tr>
                                    <td></td>
                                    <td>
                                        <button type="submit" class="btn btn-info">
                                            <i class="ace-icon fa fa-check bigger-110"></i> 保存
                                        </button>
                                        <input type="reset" class="btn btn-default pull-right" value="重置">
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </form>

                    </div>
                </div>
            </div>
        </div>    <!-- /.content -->
    </section>
</div>
<script>
    $(document).ready(function() {
        set_jl_cate();
    });

    function set_jl_cate(){
        var is_open =$('#is_open').val();
        if(is_open==1){
            $('.coach_tr').hide();
        }else{
            $('.coach_tr').show();
        }

    }

    function selectUser(){
        var goods_id = [];
        //过滤选择重复商品
        $('input[name*="goods_id"]').each(function(i,o){
            goods_id.push($(o).val());
        });
        var url = '/index.php?m=Admin&c=Coach&a=search_user';
//        var url = '/index.php?m=Admin&c=Activity&a=search_activity_goods&goods_id='+goods_id+'&t='+Math.random();
        layer.open({
            type: 2,
            title: '选择用户',
            shadeClose: true,
            shade: 0.3,
            area: ['70%', '80%'],
            content: url,
        });
    }





	function call_back(table_html)
	{
		layer.closeAll('iframe');
		$('#goods_list').append(table_html);
	}


    function checkUserUpdate(){

        var name = $('input[name="name"]').val();
        var tel = $('#tel').val();
        var is_open = $('#is_open').val();
        var cate_id = $('#cate_id').val();
        var error ='';

        if(name == ''){
            error += "真实姓名不能为空\n";
        }

        if(cate_id == 0 && is_open==2){
            error += "请选择分类\n";
        }

        if(error){
            layer.alert(error, {icon: 2});  //alert(error);
            return false;
        }
        return true;

    }
</script>

</body>
</html>